from model import Model, Dao
from model.project import ProjectDao

class Sprint(Model):
    def __init__(self, _dict):
        Model.__init__(self, _dict)

        self.name = _dict['name']
        self.description = _dict['description']
        self.created = _dict['created']
        
        # plan start date and end date
        self.start = _dict['start-date']
        self.end = _dict['end-date']
        
        # associate fields
        self.project_id = _dict['project_id']

    def __repr__(self):
        return '<Sprint %r>' % self.name
    
    def get_project(self):
        dao = ProjectDao()
        return dao.find_one({'_id':self.project_id})
    
class SprintDao(Dao):
    def __init__(self):
        Dao.__init__(self, Sprint)
        self.collection = 'sprints'